package com.cal.utms.action.payment;

import com.cal.utms.dto.payment.InvestmentDto;
import com.cal.utms.model.payment.InvestmentModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class InvestmentAction extends ActionSupport implements ModelDriven<InvestmentDto> {

	private static final long serialVersionUID = 1L;

	private InvestmentDto investmentBean = new InvestmentDto();
	InvestmentModel investmentModel = new InvestmentModel();
	private int investment_id;
	private String investment_code;
	private String addresType;
	private String investments;

	public String confirmCheque() {
		investmentModel.confirmCheque(investmentBean, investments);
		return Action.SUCCESS;
	}

	public String getunconfirmCheque() {
		investmentBean.setSuccess(true);
		investmentBean.setInvestmentBeans(investmentModel.getUnConfirmedCheques());
		return Action.SUCCESS;
	}

	public String cancelConfirmedInvestment() {
		investmentModel.cancellation(investment_id, investmentBean);
		return Action.SUCCESS;
	}

	public String updateStatus() {
		investmentModel.updateStatus(investment_id, investmentBean, addresType);
		return Action.SUCCESS;
	}

	public String getAllConfirmedInvestment() {
		investmentBean.setSuccess(true);
		investmentBean.setInvestmentBeans(investmentModel.getConfirmedInvestments());
		return Action.SUCCESS;
	}

	public String getInvestment() {
		investmentBean.setSuccess(true);
		investmentModel.getInvestmentByCode(investment_code, investmentBean);
		return Action.SUCCESS;
	}

	public String getAllInitalInvestment() {
		investmentBean.setSuccess(true);
		investmentBean.setInvestmentBeans(investmentModel.getAllInitalInvestment());
		return Action.SUCCESS;
	}

	public String saveInvestment() {
		investmentModel.saveInvestment(investmentBean);
		return Action.SUCCESS;
	}

	public String investmentUpdate() {
		investmentModel.updateInvestment(investmentBean, investment_id);
		return Action.SUCCESS;
	}

	public String getAllInvestment() {
		investmentBean.setSuccess(true);
		investmentBean.setInvestmentBeans(investmentModel.createInvestmentBeanList());
		return Action.SUCCESS;
	}

	public String confirmInv() {
		investmentModel.confirm(investmentBean, investment_id);
		return Action.SUCCESS;
	}

	public String reject() {
		investmentModel.rejectInvestment(investment_id, investmentBean);
		return Action.SUCCESS;
	}

	@Override
	public InvestmentDto getModel() {
		return investmentBean;
	}

	public InvestmentDto getInvestmentBean() {
		return investmentBean;
	}

	public void setInvestmentBean(InvestmentDto investmentBean) {
		this.investmentBean = investmentBean;
	}

	public int getInvestment_id() {
		return investment_id;
	}

	public void setInvestment_id(int investment_id) {
		this.investment_id = investment_id;
	}

	public String getInvestment_code() {
		return investment_code;
	}

	public void setInvestment_code(String investment_code) {
		this.investment_code = investment_code;
	}

	public String getAddresType() {
		return addresType;
	}

	public void setAddresType(String addresType) {
		this.addresType = addresType;
	}

	public String getInvestments() {
		return investments;
	}

	public void setInvestments(String investments) {
		this.investments = investments;
	}

}
